package bo;

import java.util.ArrayList;

import dao.BookManagementDAO;
import exception.DAOException;

import bean.Book;

public class BookManagementBO {
	
	BookManagementDAO bookManagementDAO = new BookManagementDAO();

	public ArrayList<Book> getAllBook(String keyword, String searchBy, int currentPage) throws DAOException {
		return bookManagementDAO.getAllBook(keyword, searchBy, currentPage);
	}

	public int getTotalBookPage(String keyword, String searchBy) throws DAOException {
		
		int numberOfPage = 0;
		
		numberOfPage = (int) Math.ceil((double) bookManagementDAO
				.getTotalBookRow(keyword, searchBy)
				/ 20);
		return numberOfPage;
	}

	public ArrayList<Book> getAllBook(int currentPage) throws DAOException {
		return bookManagementDAO.getAllBook(currentPage);
	}

	public int getTotalBookPage() throws DAOException {
		
		int numberOfPage = 0;
		
		numberOfPage = (int) Math.ceil((double) bookManagementDAO
				.getTotalBookRow()
				/ 20);
		return numberOfPage;
	}

	
}
